import service from './axios.js'

// 构建包含用户名的获取公钥的请求URL
export function getPublicKey(params) {
    return service({
        url: `/api/getPublicKey`,
        method: 'get',
        params,
    })
}

// 登录
export function login(data) {
    return service({
        url: `/api/login`,
        method: 'POST',
        data,
    })
}

// 灯塔总览接口
export function TowerZongLan() {
    return service({
        url: `/api/opt/lamp/TowerZongLan`,
        method: 'GET',
    })
}

// 灯桥总览接口
export function BrigeZongLan() {
    return service({
        url: `/api/opt/lamp/BrigeZongLan`,
        method: 'GET',
    })
}

// 灯类型的修改 { CCID, topic，lightnameFact，newLightType }
export function updateLightType(data) {
    return service({
        url: `/api/opt/lamp/updateLightType`,
        method: 'POST',
        data
    })
}

//灯塔操作类型的修改--自动/手动 {towerId,newManual，towerArea，towerNumber}
export function updateTowerManual(data) {
    return service({
        url: `/api/opt/lamp/updateTowerManual`,
        method: 'POST',
        data
    })
}

//灯桥操作类型的修改 {brigeId,newManual，brigeArea，brigeNumber}
export function updateBrigeManual(data) {
    return service({
        url: `/api/opt/lamp/updateBrigeManual`,
        method: 'POST',
        data
    })
}


//映射：根据网关名和现场灯名改开关名  {gatewayName，topic， lightNameFact， oldLightName, newLightName}
export function UpdateLightFact(data) {
    return service({
        url: `/api/opt/lamp/UpdateLightFact`,
        method: 'POST',
        data
    })
}

//新增灯 {gatewayId，lightname，lightnameFact，manual，lightType}
export function insertLight(data) {
    return service({
        url: `/api/opt/lamp/insertLight`,
        method: 'POST',
        data
    })
}

//新增灯塔操作 { towername， towerArea }
export function insertNewTower(data) {
    return service({
        url: `/api/opt/lamp/insertNewTower`,
        method: 'POST',
        data
    })
}

//删除灯塔
export function deleteInsertedTower(params) {
    return service({
        url: `/api/opt/lamp/deleteInsertedTower`,
        method: 'GET',
        params
    })
}

//删除灯具
export function deleteLight(params) {
    return service({
        url: `/api/opt/lamp/deleteLight`,
        method: 'GET',
        params
    })
}

//灯具开启关闭 {gatewayName,topic,lamp,action,commandMegStr，1c1}
export function sendCommandLightMsg(data) {
    return service({
        url: `/api/opt/lamp/sendCommandLightMsg`,
        method: 'POST',
        data
    })
}


//刷新命令
export function refreshGatewayData(data) {
    return service({
        url: `/api/opt/lamp/refreshGatewayData`,
        method: 'POST',
        data
    })
}

//判断网关
export function judgeLightOnline(params) {
    return service({
        url: `/api/opt/lamp/judgeLightOnline`,
        method: 'GET',
        params
    })
}



// 获取所有日志
export function getLogs(params) {
    return service({
        url: `/api/opt/user/getLogs`,
        method: 'GET',
        params
    })
}

// 获取所有用户信息
export function getAllUser(params) {
    return service({
        url: `/api/opt/user/getAllUser`,
        method: 'GET',
        params
    })
}

// 导出日志
export function exportLogsByTime(data) {
    return service({
        url: `/api/opt/user/exportLogsByTime`,
        method: 'POST',
        data
    })
}

//年报表
export function exportYearEnergy(params) {
    return service({
        url: `/api/opt/lamp/exportYearEnergy`,
        method: 'GEt',
        params
    })
}






// 删除用户 username:'123'
export function deleteByUserName(data) {
    return service({
        url: `/api/opt/user/deleteByUserName`,
        method: 'POST',
        data
    })
}

// 批量删除用户 username:【'123'，'123'】
export function deleteListByUserName(data) {
    return service({
        url: `/api/opt/user/deleteListByUserName`,
        method: 'POST',
        data
    })
}

// 修改用户角色   username: '123', role: 0
export function updateRoleByUserName(data) {
    return service({
        url: `/api/opt/user/updateRoleByUserName`,
        method: 'POST',
        data
    })
}

// 修改用户密码   username: '123', password: 加密后密码
export function updatePwdByUserName(data) {
    return service({
        url: `/api/opt/user/updatePwdByUserName`,
        method: 'POST',
        data
    })
}

// 修改用户 { username: '111', locked: '0', role: '0', password: 加密后 }
export function editByUserName(data) {
    return service({
        url: `/api/opt/user/editByUserName`,
        method: 'POST',
        data
    })
}

// 注册用户   username: '123', password: 加密后密码
export function registerUser(data) {
    return service({
        url: `/api/opt/user/registerUser`,
        method: 'POST',
        data
    })
}


//日报表画面渲染接口  buildingName=二区灯桥&startTimeStr=2024-12-03&endTimeStr=2024-12-05
export function EnergyGet(params) {
    return service({
        url: `/api/EnergyGet`,
        method: 'GET',
        params
    })
}

//日报表   http://sushijie.natappvip.cc/DayEnergyGet?buildingName=二区灯桥&startTimeStr=2024-12-03&endTimeStr=2024-12-05
export function DayEnergyGet(params) {
    return service({
        url: `/api/opt/lamp/DayEnergyGet`,
        method: 'GET',
        params
    })
}


//年报表画面渲染接口 buildingName=二区灯桥   开始 结束 时间。为空
export function YearEnergyGet(params) {
    return service({
        url: `/api/opt/lamp/YearEnergyGet`,
        method: 'GET',
        params
    })
}

//月报表画面渲染接口 buildingName=二区灯桥&startTimeStr=2024-12&endTimeStr=2025-01   7月-12月。往前5个月
export function MonthEnergyGet(params) {
    return service({
        url: `/api/opt/lamp/MonthEnergyGet`,
        method: 'GET',
        params
    })
}

//自动控制配置
export function AutoStatus() {
    return service({
        url: `/api/opt/lamp/AutoStatus`,
        method: 'GET',
    })
}

//自动控制 提交
export function cronAutoFlag(data) {
    return service({
        url: `/api/opt/lamp/cronAutoFlag`,
        method: 'POST',
        data
    })
}


//灯光设置-开启
export function cronStart(data) {
    return service({
        url: `/api/opt/lamp/cronStart`,
        method: 'POST',
        data
    })
}

//灯光设置-关闭
export function cronEnd(data) {
    return service({
        url: `/api/opt/lamp/cronEnd`,
        method: 'POST',
        data
    })
}

//更换网关  /opt/lamp/changeGateway?gatewayId=123（123为用户选择的gatewayName所属的gatewayID）
export function changeGateway(params) {
    return service({
        url: `/api/opt/lamp/changeGateway`,
        method: 'GET',
        params
    })
}

//三相电流
export function lampElectric(params) {
    return service({
        url: `/api/opt/lamp/Electric`,
        method: 'GET',
        params
    })
}

//电流报表
export function lampeEectricLogs(params) {
    return service({
        url: `/api/opt/lamp/electricLogs`,
        method: 'GET',
        params
    })
}

//巡检报表
export function lampeInspectionLogs(params) {
    return service({
        url: `/api/opt/lamp/inspectionLogs`,
        method: 'GET',
        params
    })
}

//维修报表
export function lampeRepairLogs(params) {
    return service({
        url: `/api/opt/lamp/repairLogs`,
        method: 'GET',
        params
    })
}

//自动控制开关灯 -- 提交
export function lampChangeAutoMethod(data) {
    return service({
        url: `/api/opt/lamp/changeAutoMethod`,
        method: 'POST',
        data
    })
}

//一键巡检
export function lampCheck(params) {
    return service({
        url: `/api/opt/lamp/Check`,
        method: 'GET',
        params
    })
}


//光照强度
export function getLightness(params) {
    return service({
        url: `/api/opt/lamp/getLightness`,
        method: 'GET',
        params
    })
}

//设置光照强度
export function setLightness(params) {
    return service({
        url: `/api/opt/lamp/setLightness`,
        method: 'GET',
        params
    })
}


//自动状态接口
export function getAutoCheckFlag(params) {
    return service({
        url: `/api/opt/lamp/getAutoCheckFlag`,
        method: 'GET',
        params
    })
}

//更改建筑
export function changeBuildingLocaitonUi(params) {
    return service({
        url: `/api/opt/lamp/changeBuildingLocaitonUi`,
        method: 'POST',
        data: params
    })
}

//设置建筑标准电流
//{ buildingName, standardElectric }
export function setStandardElectric(params) {
    return service({
        url: `/api/opt/lamp/setStandardElectric`,
        method: 'GET',
        params
    })
}

export function getAllGatewayList(params) {
    return service({
        url: `/api/opt/lamp/getAllGatewayList`,
        method: 'GET',
        params
    })
}

export function CheckByGateway(params) {
    return service({
        url: `/api/opt/lamp/CheckByGateway`,
        method: 'GET',
        params
    })
}

export function repairLogsChanged(params) {
    return service({
        url: `/api/opt/lamp/repairLogsChanged`,
        method: 'GET',
        params
    })
}

export function checkGetProgress(params) {
    return service({
        url: `/api/opt/lamp/checkGetProgress`,
        method: 'GET',
        params
    })
}

export function stopCheck(params) {
    return service({
        url: `/api/opt/lamp/stopCheck`,
        method: 'get',
        params
    })
}


export function inspectionLogsSecond(params) {
    return service({
        url: `/api/opt/lamp/inspectionLogsSecond`,
        method: 'get',
        params
    })
}


export function savePercent(params) {
    return service({
        url: `/api/opt/lamp/savePercent`,
        method: 'get',
        params
    })
}

export function getEnforceAutoFlag(params) {
    return service({
        url: `/api/opt/lamp/getEnforceAutoFlag`,
        method: 'get',
        params
    })
}

export function setEnforceAutoFlag(params) {
    return service({
        url: `/api/opt/lamp/setEnforceAutoFlag`,
        method: 'get',
        params
    })
}

export function autoControlReportFirst(params) {
    return service({
        url: `/api/opt/lamp/autoControlReportFirst`,
        method: 'get',
        params
    })
}

export function autoControlReportSecond(params) {
    return service({
        url: `/api/opt/lamp/autoControlReportSecond`,
        method: 'get',
        params
    })
}

//日节能报表接口
export function DaySaveEnergyGet(params) {
    return service({
        url: `/api/opt/lamp/DaySaveEnergyGet`,
        method: 'GET',
        params
    })
}

//月节能报表接口：
export function MonthSaveEnergyGet(params) {
    return service({
        url: `/api/opt/lamp/MonthSaveEnergyGet`,
        method: 'GET',
        params
    })
}

//年节能报表接口：
export function YearSaveEnergyGet(params) {
    return service({
        url: `/api/opt/lamp/YearSaveEnergyGet`,
        method: 'GET',
        params
    })
}



